import { ApiProperty } from '@nestjs/swagger';
import { Transform } from 'class-transformer';
import {
  IsIn,
  IsInt,
  IsNotEmpty,
  IsOptional,
  IsString,
  Min,
} from 'class-validator';
import { ParamsDto } from './params.dto';

// 1. 定义DTO
export class QueryParamsDto extends ParamsDto {
  @Transform(({ value }) => parseInt(value))
  @IsInt()
  @Min(1)
  @ApiProperty({ title: '页码', required: false })
  page: number = 1;

  @Transform(({ value }) => parseInt(value))
  @IsOptional()
  @IsInt()
  @Min(1)
  @ApiProperty({ title: '页大小', required: false })
  limit: number = 10;

  @IsOptional()
  @IsString()
  @IsIn(['ASC', 'DESC'])
  @ApiProperty({ title: '排序', required: false })
  orderBy: 'ASC' | 'DESC' = 'ASC';
}
